Skip to content

perf: use native directory checks on Unix#1291

Open
krystophny wants to merge 1 commit into
fortran-lang:mainfrom
krystophny:perf/native-is-dir
Open

perf: use native directory checks on Unix#1291
krystophny wants to merge 1 commit into
fortran-lang:mainfrom
krystophny:perf/native-is-dir

Conversation

@krystophny

@krystophny krystophny commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Use the existing C c_is_dir wrapper for Unix directory checks instead of shelling out
  • Bootstrap path keeps the old shell command

Context

Part of the parallel build safety and performance work. Removes shell overhead
from is_dir by using the existing C binding on Unix. Neutral on fpm self-build
(compiler time dominates), but eliminates fork calls that are unsafe under
OpenMP threads.

Merge order

Independent PRs (any order):

Stacked chain (merge in order):

  1. Fortran compiles via argv (feat: exec Fortran compiles via argv (posix_spawn/CreateProcess) #1299)
  2. Parallel link/archive via argv (feat: run link and archive in parallel via argv spawn #1300)
  3. C/C++ compiles via argv (feat: exec C/C++ compiles via argv, close the shell-fork gap #1301)

Fork-safety fix:

After the above:

Verification

fpm self-build and full test suite pass:

$ fpm build --features openmp --compiler gfortran --flag '-O3 -g'
[100%] Project compiled successfully.

$ fpm test
TALLY;TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
PASSED: all 35 tests passed

Benchmark (fpm self-build, median of 3):

parallel: 21.17s main, 21.10s branch, 0.07s faster, 0.3%
serial:   24.90s main, 24.91s branch, 0.01s slower, 0.0%

Neutral — compile time dominates; the shell overhead removal matters for
the parallel safety story, not for this benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant